//
//  ELMobClick.m
//  jobClient
//
//  Created by 一览iOS_2 on 2018/7/16.
//  Copyright © 2018年 YL1001. All rights reserved.
//

#import "ELMobClick.h"

@implementation ELMobClick

+ (void)event:(NSString *)event {
    if (!event) {
        [MobClick event:event];
    }
}

+ (void)event:(NSString *)event attributes:(NSDictionary *)attributes {
    NSMutableDictionary *attributesDic = attributes?[[NSMutableDictionary alloc] initWithDictionary:attributes]:[NSMutableDictionary dictionary];
    if (StringIsNotEmpty([Manager getUserInfo].userId_)) {
        [attributesDic setObject:[Manager getUserInfo].userId_ forKey:@"person_id"];
    }
    [attributesDic setObject:@"iOS" forKey:@"phone"];
    [attributesDic setObject:Version_Show forKey:@"version"];
    if (DictIsEmpty(attributesDic)) {
        [MobClick event:event];
        return;
    }
    [MobClick event:event attributes:attributesDic];
}

+ (void)event:(NSString *)event attributes:(NSDictionary *)attributes counter:(int)number {
    NSMutableDictionary *attributesDic = [[NSMutableDictionary alloc] initWithDictionary:attributes];
    if (StringIsNotEmpty([Manager getUserInfo].userId_)) {
        [attributesDic setObject:[Manager getUserInfo].userId_ forKey:@"person_id"];
    }
    if (DictIsEmpty(attributesDic)) {
        [MobClick event:event];
        return;
    }
    [MobClick event:event attributes:attributesDic counter:number];
}

// v7.76.2 首页职业报告点击-后台统计 (金刚区，报告板块更多，十大分类按钮)
// pageType页面类型 10:首页的《专业报告》icon 、20:首页的《专业报告》更多、 30 报告分类icon
+ (void)event:(int)comefrom majorId:(NSString *)majorId majorName:(NSString *)majorName identityType:(NSString *)type{
    NSMutableDictionary *info = [NSMutableDictionary dictionary];
    [info setValue:[Manager getUserInfo].userId_ forKey:@"personId"];
    
    [info setValue:@"OCCUPATION_MODULE_TYPE" forKey:@"moduleType"];
    [info setValue:@"10" forKey:@"platform"];
    [info setValue:@(comefrom) forKey:@"pageType"];
    [info setValue:majorId forKey:@"majorId"];
    [info setValue:majorName forKey:@"majorName"];
    [info setValue:type?type:@"20" forKey:@"identityType"]; // 10 应届毕业生 20 社会人才
    HPRequestModel *md = [[HPRequestModel alloc] init];
    md.postParams = [md paramFormat:info];
//    [md paramsConfigWithOp:@"activityOpen" func:@"clickReport" tokenType:ATokenTypeJava];
    [md paramsConfigWithOp:@"activityOpen" func:@"clickReport" tokenType:ATokenTypeJavaWebServe];
    [HPNetworking postWithModel:md succeed:^(id  _Nullable result) {
        NSLog(@"---1111");
    } failure:nil];
}
// v7.76.2 保存点击记录
+ (void)eventActivityId:(NSString *)activityId activityName:(NSString *)activityName{
    NSMutableDictionary *info = [NSMutableDictionary dictionary];
    [info setValue:[Manager getUserInfo].userId_ forKey:@"browsePersonId"];
    [info setValue:@"OCCUPATION_MODULE_TYPE" forKey:@"moduleType"];
    [info setValue:activityId forKey:@"mpaActivityId"];
    [info setValue:activityName forKey:@"activityName"];
    
    HPRequestModel *md = [[HPRequestModel alloc] init];
    md.postParams = [md paramFormat:info];
//    [md paramsConfigWithOp:@"activityOpen" func:@"appAddBrowseRecord" tokenType:ATokenTypeJava];
    [md paramsConfigWithOp:@"activityOpen" func:@"appAddBrowseRecord" tokenType:ATokenTypeJavaWebServe];
    [HPNetworking postWithModel:md succeed:^(id  _Nullable result) {
        NSLog(@"---2222");
    } failure:nil];
}


/*
 * v8.15.3 保存点击记录
 *BuryingId:后台返回的id（可不传）
 *etId：事件id（问后端具体数据）
 *cardType：卡类型（可不传）
 *consultantId：顾问id（可不传）
 *jumpPersonId：来源用户id
 *jumpSource：跳转来源类型 10：小程序  20：ios 30：安卓
 *jumpEtId：跳转来源事件id(当统计漏斗分析时使用)
 */
+ (void)zhiTuEventId:(NSString *)etId
        jumpPersonId:(NSString *)jumpPersonId
          jumpSource:(NSString *)jumpSource
            jumpEtId:(NSString *)jumpEtId{
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    [param setValue:etId forKey:@"etId"];
    [param setValue:[Manager getUserInfo].userId_ forKey:@"personId"];
    [param setValue:[Manager getUserInfo].userId_ forKey:@"jumpPersonId"];
    [param setValue:jumpSource forKey:@"jumpSource"];
    [param setValue:jumpEtId forKey:@"jumpEtId"];
    
    HPRequestModel *md = [[HPRequestModel alloc] init];
    md.postParams = [md paramFormat:param];
    [md paramsConfigWithOp:@"eventLog" func:@"addBuryingPoint" path:PATH_CAREER];
    [HPNetworking postWithModel:md succeed:^(id  _Nullable result) {
        NSLog(@"-----------addBuryingPoint---------------etId:\n%@---%@",etId,jumpEtId);
    } failure:nil];
}


@end
